
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:provider/provider.dart';

import 'BaseVMProvide.dart';

abstract class PageProvideNode<T extends BaseVMProvide> extends StatelessWidget{

  //注入生成 Provider   params为 构造函数的参数（注意：需要按照顺序）  // 此注入框架  未做空判定  无法使用 后续 可以考虑仿写
  // PageProvideNode() : this.mProvider=inject(params: List.empty());
  final T mProvider;

  PageProvideNode(this.mProvider);

  Widget buildContent(BuildContext context);

  @override
  Widget build(BuildContext context) {
     return ChangeNotifierProvider.value(value: mProvider,child: buildContent(context));
  }
}

// abstract class PageProvidefulNode<T extends BaseVMProvide> extends StatefulWidget {
//
//   final T mProvider;
//
//   PageProvidefulNode(this.mProvider);
//
//   Widget buildContent(BuildContext context);
//
//   @override
//   _PageProvidefulNodeState createState() => _PageProvidefulNodeState(ChangeNotifierProvider.value(value: mProvider,child: buildContent(context)));
//
// }
//
// class _PageProvidefulNodeState<T extends BaseVMProvide> extends State<PageProvidefulNode<T>> {
//
//   var widget;
//
//   _PageProvidefulNodeState(this.widget)
//
//   @override
//   Widget build(BuildContext context) {
//     return widget;
//   }
//
// }
